#ifndef ADVKSWAPCHAIN_H
#define ADVKSWAPCHAIN_H

#include "AdVKCommon.h"

namespace ade{
    class AdVKGraphicContext;
    class AdVKDevice;

    struct SurfaceInfo{
        VkSurfaceCapabilitiesKHR capabilities;
        VkSurfaceFormatKHR surfaceFormat;
        VkPresentModeKHR presentMode;
    };

    class AdVKSwapchain{
    public:
        AdVKSwapchain(AdVKGraphicContext *context, AdVKDevice *device);
        ~AdVKSwapchain();

        bool ReCreate();

        int32_t AcquireImage() const;
        void Present(int32_t imageIndex) const;

        const std::vector<VkImage> &GetImages() const { return mImages; }
        uint32_t GetWidth() const { return mSurfaceInfo.capabilities.currentExtent.width; }
        uint32_t GetHeight() const { return mSurfaceInfo.capabilities.currentExtent.height; }
    private:
        void SetupSurfaceCapabilities();

        VkSwapchainKHR mHandle = VK_NULL_HANDLE;

        AdVKGraphicContext *mContext;
        AdVKDevice *mDevice;
        std::vector<VkImage> mImages;

        SurfaceInfo mSurfaceInfo;
    };
}

#endif